module oderogue.tcod.system;

import derelict.tcod.libtcod;

/**
 * Limit the number of frames per second. If a frame is rendered faster than expected, the TCOD_console_flush function 
 * will wait so that the frame rate never exceed this value.
 * You can call this function during your game initialization.
 * You can dynamically change the frame rate. Just call this function once again.
 *
 * Params:
 *   fps: Maximum number of frames per second. 0 means unlimited frame rate.
 */
public void setFPS(int fps)
{
	TCOD_sys_set_fps(fps);
}

/**
 * Returns the actual number of frames rendered during the last second. This value is updated every second.
 */
public int getFPS()
{
	return TCOD_sys_get_fps();
}

/**
 * Return the length in seconds of the last rendered frame.
 * You can use this value to update every time dependant object in the world.
 */
public float getLastFrameLength()
{
	return TCOD_sys_get_last_frame_length();
}

/**
 * Stops the program execution for the given time in milliseconds.
 *
 * Params:
 *   time: The sleep time in milliseconds.
 */
public void sleep(int time)
{
	TCOD_sys_sleep_milli(time);
}

/**
 * Returns the number of milliseconds since the program has started.
 */
public int getElapsedTimeMillis()
{
	return TCOD_sys_elapsed_milli();
}

/**
 * Returns the number of seconds since the program has started.
 */
public float getElapsedTimeSeconds()
{
	return TCOD_sys_elapsed_seconds();
}

/**
 * Save the current game screen in a png file, or possibly a bmp file if you provide a filename ending with .bmp.
 *
 * Params:
 *   fileName: Name of the file. If null, a filename is automatically generated with the form "./screenshotNNN.png", 
 *     NNN being the first free number (if a file named screenshot000.png already exist, screenshot001.png will be used, 
 *     and so on...).
 */
public void saveScreenShot(string fileName)
{
	TCOD_sys_save_screenshot(std.string.toStringz(fileName));
}

/**
 * This function allows you to force the use of a specific resolution in fullscreen mode.
 * The default resolution depends on the root console size and the font character size.
 *
 * Will use the smallest available resolution so that :
 *   resolution width >= width and resolution width >= root console width * font char width
 *   resolution width >= height and resolution height >= root console height * font char height
 */
public void forceFullscreenResolution(int width, int height)
{
	TCOD_sys_force_fullscreen_resolution(width, height);
}

/**
 * You can get the current screen resolution with getCurrentResolution. You can use it for example to get the desktop 
 * resolution before initializing the root console.
 */
public void getCurrentResolution(out int width, out int height)
{
	TCOD_sys_get_current_resolution(&width, &height);
}

/**
 * Get the current font character size.
 */
public void getCharSize(out int width, out int height)
{ 
	TCOD_sys_get_char_size(&width, &height);
}


